package org.dslmagic.interpreter;

import org.dslmagic.data.Group;
import org.dslmagic.data.Transformer;

public class BaseDslInterpreter {

	private DslContext context = null;

	public DslContext getContext() {
		return context;
	}

	public void setContext(DslContext context) {
		this.context = context;
	}

	protected void set(String name, Object value) {
		context.set(name, value);
	}

	protected void unset(String name) {
		context.unset(name);
	}

	protected Boolean varbool(String name) {
		return (Boolean) Transformer.TO_BOOL.transform(context.get(name));
	}

	protected Object varobj(String name) {
		return Transformer.TO_OBJ.transform(context.get(name));
	}

	protected String varstr(String name) {
		return (String) Transformer.TO_STR.transform(context.get(name));
	}

	protected Integer varnum(String name) {
		return (Integer) Transformer.TO_INT.transform(context.get(name));
	}

	protected Group vargroup(String name) {
		return (Group) Transformer.TO_GROUP.transform(context.get(name));
	}

}
